package com.tf_cut.backend.agent.statistics.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.tf_cut.backend.agent.statistics.service.AgentCommissionService;
import com.tf_cut.backend.agent.statistics.vo.AgentCommissionVo;
import com.tf_cut.backend.common.pojo.PageInfo;
import com.tf_cut.backend.common.pojo.Result;

import lombok.extern.slf4j.Slf4j;


@RestController
@RequestMapping("/backend/agent/cms/")
@Slf4j
public class AgentCommissionController {
	
	@Autowired
	private AgentCommissionService agentCommissionService;
	
	// 获取代理商季度待结分润
	@RequestMapping("getAlreadyCommission")
    public String getQuarterCommission(String json) {
		Result<PageInfo<AgentCommissionVo>> result = null;
		try {
			AgentCommissionVo vo = JSON.parseObject(json, AgentCommissionVo.class);
			result = Result.of(agentCommissionService.findAlreadyCommission(vo));
		}catch (Exception e) {
			String msg = "查询代理商已结分润失败！condition："+json;
			log.error(msg, e);
			result = Result.of(null, false, msg);
		}
        return JSON.toJSONString(result,SerializerFeature.WriteDateUseDateFormat);
    }
}
